<?php
// Language translation functionality.
// Part of mmvc library, https://code.google.com/p/mmvc/
// Dependencies: None

/**
 * Returns named text string from global array $g_texts of text strings to be translated.
 * If multiple parameters are passed to this function, sprintf is used to format the string.
 * Arguments: Name of the text string, followed by optional arguments passed to sprintf.
 * @return Translated string or the original string if translation not found.
 */
function __() {
	global $g_texts;
	if (!isset($g_texts)) $g_texts = array();
	$a = func_get_args();
	$k = array_shift($a);
	if ( array_key_exists($k,$g_texts) ) {
		$s = $g_texts[$k];
	}
	else {
		$s = $k;
	}
	return empty($a) ? $s : @vsprintf($s,$a); 
} 

?>